package hichecker.ui.general_views.container_panel.content;

import hichecker.controller.Config;
import hichecker.tools.export.CSVFile;
import hichecker.university.UniversityPart;

import java.util.ArrayList;
import java.util.List;

import javax.swing.JOptionPane;
import javax.swing.JPanel;

public abstract class ContentPanel extends JPanel {
	protected UniversityPart item;

	public ContentPanel(UniversityPart item) {
		this.item = item;
	}

	/**
	 * Schaltet zwischen Daten- und Einstellungsansicht um.
	 * @return Die jeweils andere Ansicht als ContentPanel
	 */
	public abstract ContentPanel switchViewSettings();

	/**
	 * Liefert das dargestellte Element
	 * @return UniversityPart
	 */
	public UniversityPart getItem() {
		return item;
	}

	/**
	 * Prüft, ob aktuell Veränderungen vorliegen
	 * @return
	 */
	public boolean isCorrect() {
		return true;
	}

	public boolean userConfirmed() {
		int answer = JOptionPane.showConfirmDialog(ContentPanel.this,
				Config.CONTENT_CONFIRM_DELETE, Config.CONTENT_CONFIRM_DELETE_HEADER,
				JOptionPane.YES_NO_OPTION);
		return answer == JOptionPane.YES_OPTION;
	}

	public List<CSVFile> toCSV(String topLevel) {
		return new ArrayList<CSVFile>();
	}
}
